extends Node2D

signal upgrade
signal act

@onready var anima: AnimationPlayer = $AnimationPlayer

var upgrade_time = 0

var initial_points = 0

func _ready() -> void:
    pass

func _update() -> void:
    match upgrade_time:
        0:
            upgrade.emit()
            upgrade_time = 1

        1:
            upgrade_time = 2
        
        2:
            upgrade_time = 3

        3:
            upgrade_time = 4

        4:
            upgrade_time = 5

func active() -> void:
    anima.play("ready")
    match upgrade_time:
        1:
            get_parent().cool_down_time = 0.2
            await get_tree().create_timer(3).timeout
            anima.play_backwards("ready")
            get_parent().cool_down_time = 0.25
        2:
            get_parent().cool_down_time = 0.2
            await get_tree().create_timer(5).timeout
            anima.play_backwards("ready")
            get_parent().cool_down_time = 0.25
        3 || 4:
            get_parent().cool_down_time = 0.1
            await get_tree().create_timer(5).timeout
            anima.play_backwards("ready")
            get_parent().cool_down_time = 0.25
        5:
            get_parent().cool_down_time = 0.1
            initial_points = Global.kill_nums
            await get_tree().create_timer(5).timeout
            anima.play_backwards("ready")
            get_parent().cool_down_time = 0.25
            Global.current_hp += Global.kill_nums - initial_points
